package com.pro01.backend.controller;

import com.pro01.backend.dto.UserRatioDTO;
import com.pro01.backend.pojo.Result;
import com.pro01.backend.service.RatioService;
import com.pro01.backend.utils.TokenUtil;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/users")
public class RatioController {

    @Autowired
    private RatioService ratioService;

    /**
     * 获取当前用户的上传、下载、分享率信息
     */
    @GetMapping("/my-ratio")
    public Result<UserRatioDTO> getMyTrafficStats(HttpServletRequest request) {
        Long userId = TokenUtil.getUserId(request);
        UserRatioDTO dto = ratioService.getUserRatio(userId);
        return Result.success(dto);
    }


    @GetMapping("/my-rewarded-ratio")
    public Result<UserRatioDTO> getMyRewardedRatio(HttpServletRequest request) {
        Long userId = TokenUtil.getUserId(request);
        UserRatioDTO dto = ratioService.getUserRewardedRatio(userId);
        return Result.success(dto);
    }

}

